package InheritanceAndPolymorphism.demo02;

public class Test {
    /**
     * 定义一个Animal类型的变量a，并将不同子类的实例赋给a；
     *    	调用eat();观察结果后，并理解多态
     * @param args
     */
    public static void main(String[] args) {
        Animal a;
        a = new Cat();
        a.eat();
        a = new Dog();
        a.eat();
        a = new Eagle();
        a.eat();

        a = new Cat();
        if (a instanceof Cat) {
            Cat cat = (Cat) a;
            cat.CatSpeak();
        }
    }
}
